using System.Collections;
using UnityEngine;

public class LobbyGold : MonoBehaviour
{
	public static LobbyGold instance;

	public float appearanceTime = 2f;

	public float alphaTime = 1f;

	public Animation goldAnimation;

	public GameObject firstOn;

	public GameObject secondOn;

	public LocalizeObject goldLabel;

	private Material material;

	private void Awake()
	{
		instance = this;
		material = GetComponentInChildren<Renderer>().sharedMaterial;
		Color color = material.GetColor("_Color");
		color.a = 0f;
		goldLabel.a = 0f;
		material.SetColor("_Color", color);
	}

	private void Start()
	{
		StartCoroutine(ShowObject());
	}

	private void OnDestroy()
	{
		instance = null;
	}

	private IEnumerator ShowObject()
	{
		yield return new WaitForSeconds(appearanceTime);
		Color color = material.GetColor("_Color");
		float time = Time.time;
		firstOn.SetActive(true);
		while (time + alphaTime > Time.time)
		{
			color.a = (Time.time - time) / alphaTime / 2f;
			goldLabel.a = color.a;
			material.SetColor("_Color", color);
			yield return null;
		}
		secondOn.SetActive(true);
		color.a = 1f;
		goldLabel.a = 1f;
		material.SetColor("_Color", color);
		goldAnimation.Play();
	}
}
